//
//  BaseNavigationController.m
//  SWS
//
//  Created by zjszyms on 16/1/12.
//  Copyright © 2016年 zjszyms. All rights reserved.
//

#import "BaseNavigationController.h"

@interface BaseNavigationController ()

@end

@implementation BaseNavigationController


- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    self.tabBarController.hidesBottomBarWhenPushed = YES;
    
    if (self.viewControllers.count)
    {
        viewController.hidesBottomBarWhenPushed = YES;
        
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 44, 44)];
        [button setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateHighlighted];
        [button setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateSelected];
        [button addTarget:self action:@selector(leftbarButtonItemOnclick:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *barbuttonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
        
        viewController.navigationItem.leftBarButtonItem = barbuttonItem;
    }

    [super pushViewController:viewController animated:animated];
}

- (void)leftbarButtonItemOnclick:(id)sender
{
    [self popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
